<?php
class classImage{
	function upload($dir, $image, $newName){
		if (is_uploaded_file($image['tmp_name'])){
			$imageName = $image['name'];
			//name
			//TODO controlar por JAVASCRIPT QUE SEA JPG
			$imageName1 = explode(".",$imageName);
			$imageName2 = $newName.".".$imageName1[1];
			
			//select directory
			move_uploaded_file($image['tmp_name'], $dir.$imageName2);
			
			//chmod
			$dirFile=$dir.$imageName2;
			chmod($dirFile,0777);
		}		
	}
	
}